﻿using System.Web;

namespace HooIzDat.Web.Models
{
    public abstract class Repository
    {
        private const string DbKey = "HooIzDatEntities";

        protected HooIzDatEntities Db
        {
            get
            {
                HooIzDatEntities context = null;
                if (!HttpContext.Current.Items.Contains(DbKey))
                {
                    HttpContext.Current.Items[DbKey] = new HooIzDatEntities();
                }
                context = HttpContext.Current.Items[DbKey] as HooIzDatEntities;
                return context;
            }
        }
    }
}